/*
 * @Description:
 * @Author:  huangshuai
 * @Date: 2023-10-22 09:06:03
 * @LastEditTime: 2023-10-27 16:19:52
 * @LastEditors: huangshuai
 */
/*
 * @Description:
 * @Author:  huangshuai
 * @Date: 2023-10-16 16:29:27
 * @LastEditTime: 2023-10-25 11:32:00
 * @LastEditors: huangshuai
 */
import { defineStore } from "pinia";
import { ref } from "vue";
import {
  // dynamicRouter1,
  // dynamicRouter2,
  // dynamicRouter3,
  ownerUser,
  managerUser,
  superUser,
} from "@/stores/permission";
// import { useRouter } from "vue-router";

export const useUserStore = defineStore(
  "user",
  () => {
    const userDesc = ref<any>();
    const isLogin = ref<boolean>(false);
    const loading = ref<boolean>(false);
    const roleMenu = ref<any>([]);

    // const rolePerssionRouter = ref<any>();
    // const router = useRouter();
    const handleUserMenu = (type: string) => {
      if (type === "0") {
        // rolePerssionRouter.value = dynamicRouter1;
        // router.addRoute("layout", rolePerssionRouter.value);
        return ownerUser;
      }
      if (type === "1") {
        // rolePerssionRouter.value = dynamicRouter2;
        // router.addRoute("layout", rolePerssionRouter.value);
        return managerUser;
      }
      if (type === "2") {
        // rolePerssionRouter.value = dynamicRouter3;
        // router.addRoute("layout", rolePerssionRouter.value);
        return superUser;
      }
    };
    // const rolePerssionRouter = ref<any>();
    // const router = useRouter();

    const countdown404 = ref(5);
    return {
      userDesc,
      isLogin,
      loading,
      roleMenu,
      countdown404,
      // rolePerssionRouter,
      handleUserMenu,
      // handleAddRouters,
    };
  },
  {
    persist: {
      enabled: true,
    },
  }
);
